Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@/CivicSignalBlog - Use aliases in Payload CMS #902

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

m453h
Copy link
Contributor

@m453h m453h commented Sep 27, 2024

Description

This pull request includes several changes to the civicsignalblog application, primarily focusing on using Path aliases for cleaner imports.

Additionally, it fixes failing build-next due to ESLint that were noted after merging #901.

While trying to use path aliases, it was noted that Payload does not resolve the paths as expected, this is dicussed here.

Thus, to resolve this we have:

  • Added tsconfig-paths library and updated the dev script with -r tsconfig-paths/register enabling ts-node to correctly resolve path aliases defined in tsconfig.json
  • Added a custom function in tsconfigPathToWebpackAlias.ts that create path aliases that are used in payload.config.ts
  • Added tsc-alias and updated the build-next script to include tsc-alias -p tsconfig.server.json that replaces alias paths with relative paths after typescript compilation.

P.S
The PR might have many modified files but they are mainly adding aliases. The main concern with this PR is the use of two new packages as a workaround to the Path Alias Issue. While it's not ideal, it appears to be the most viable solution for now. Perhaps we can discover a better approach during our review.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

@m453h m453h added the chore A task that needs to be done (neither enhancement or bug) label Sep 27, 2024
@m453h m453h self-assigned this Sep 27, 2024
@m453h m453h marked this pull request as ready for review September 27, 2024 08:38
@kilemensi
Copy link
Member

Just saw this custom condition approach that doesn't require extra dependencies. Did you review it / won't it work for us? We should be on TS 5.4 already.

@m453h
Copy link
Contributor Author

m453h commented Sep 27, 2024

Just saw this custom condition approach that doesn't require extra dependencies. Did you review it / won't it work for us? We should be on TS 5.4 already.

Hmm interesting... I hadn't looked at this one...let me quickly test it and get back to you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore A task that needs to be done (neither enhancement or bug)
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants